//
//  ViewController1.m
//  PASystem
//
//  Created by michael on 16/7/19.
//  Copyright © 2016年 czd. All rights reserved.
//
#import "xmtzTableViewController.h"

#import "ViewController1.h"
#import "OALoginViewController.h"
#import "xmzlTableViewController.h"
#import "ExhibitionProjectController.h"
#import "zouchuquTableViewController.h"
#import "jingwaiTableViewController.h"
#import "JMRightViewController.h"
#import "MemberOftheLibraryController.h"
#import "ConsultantController.h"
@interface ViewController1 ()

@end

@implementation ViewController1

- (void)viewDidLoad {
    [super viewDidLoad];
//    self.navigationController.navigationBar.translucent = NO;

  self.title = @"贸促数据库";
     _array = @[@"企业信息库",@"委员库",@"理事顾问库",@"投资项目",@"签约机构",@"国外客商",@"展览项目"];

//   [self _backbutton];
   self.navigationController.navigationBar.tintColor = [UIColor whiteColor];
  //创建按钮
   [self _button];
    self.view.backgroundColor = [UIColor whiteColor];


        // Do any additional setup after loading the view.
}
- (void)_button{
    float width = (kScreenWidth-80)/3.0;
    float height = (KScreenHeight-270-46)/3.0;
    UICollectionViewFlowLayout *flowlayout = [[UICollectionViewFlowLayout alloc]init];
    flowlayout.itemSize = CGSizeMake(width, height);
       flowlayout.sectionInset = UIEdgeInsetsMake(20, 10, 20, 10);
//       flowlayout.sectionInset = UIEdgeInsetsMake(<#CGFloat top#>, <#CGFloat left#>, <#CGFloat bottom#>, <#CGFloat right#>)
    flowlayout.minimumInteritemSpacing =20;
    flowlayout.minimumLineSpacing = 40;
 _collectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, kScreenHeight - 64) collectionViewLayout:flowlayout];
  _collectionView.delegate = self;
    _collectionView.dataSource = self;
    _collectionView.backgroundColor = [UIColor clearColor];
    _collectionView.backgroundView = nil;
    [_collectionView registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:@"cellid"];

    [self.view addSubview:_collectionView];
}
#pragma mark - UICollectionViewDataSource
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
    return _array.count;
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
//    static NSString * CellIdentifier = @"GradientCell";  

    UICollectionViewCell * cell  = [collectionView dequeueReusableCellWithReuseIdentifier:@"cellid" forIndexPath:indexPath];
    UIImageView *image = [[UIImageView alloc]initWithFrame:cell.contentView.frame];
    image.image = [UIImage imageNamed:_array[indexPath.row]];
    [cell.contentView addSubview:image];
    return cell;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{

NSLog(@"%@",_array[indexPath.row]);

if ([_array[indexPath.row]isEqualToString:@"展览项目"])
{
ExhibitionProjectController *vc = [[ExhibitionProjectController alloc]init];
vc.string =_array[indexPath.row];
vc.service = @"LibrarieService";
//vc.action = @"zlxmList";
vc.type = QUANBU;
[self.navigationController pushViewController:vc animated:YES];
}
if ([_array[indexPath.row]isEqualToString:@"国外客商"]) {
    xmzlTableViewController *vc = [[xmzlTableViewController alloc]init];
    vc.action = @"gwksList";
    vc.string =_array[indexPath.row];
    vc.service = @"LibrarieService";
    [self.navigationController pushViewController:vc animated:YES];

}

if ([_array[indexPath.row] isEqualToString:@"签约机构"]) {
    jingwaiTableViewController *guowai = [[jingwaiTableViewController alloc]init];
        guowai.jwstring = _array[indexPath.row];
//        guowai.type = @"4";
        guowai.action = @"qyjgList";
        guowai.service = @"LibrarieService";
    [self.navigationController pushViewController: guowai  animated:YES];
}
if ([_array[indexPath.row] isEqualToString:@"投资项目"]) {
    xmtzTableViewController *guowai = [[xmtzTableViewController alloc]init];
        guowai.string = _array[indexPath.row];
//        guowai.type = @"4";
        guowai.action = @"tzxmList";
        guowai.service = @"LibrarieService";
    [self.navigationController pushViewController: guowai  animated:YES];
}

else if ([_array[indexPath.row]isEqualToString:@"企业信息库"])
{
    
    JMRightViewController *rightVC = [[JMRightViewController alloc] init];
        rightVC.string  =_array[indexPath.row];

    [self.navigationController pushViewController:rightVC animated:YES];
}else if ([_array[indexPath.row]isEqualToString:@"委员库"])
{
    
    MemberOftheLibraryController *memVC = [[MemberOftheLibraryController alloc] init];
    [self.navigationController pushViewController:memVC animated:YES];
}else if ([_array[indexPath.row]isEqualToString:@"理事顾问库"])
{
    
    ConsultantController *conVC = [[ConsultantController alloc] init];
    
    [self.navigationController pushViewController:conVC animated:YES];
}

}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
